<layout name='Layout/layout_main' />
<script type="text/javascript">
	function add() {
		$("#form_data :input[type='hidden']").val("");
		$("#form_data :text").val("");
		$("#form_data select ").each(function() {
			$(this).find('option:first').attr('selected', 'selected');
		});
		$(".sub_left_menu tbody tr.active").removeClass("active");
		$("#opmode").val("add");
	}

	function reset_pwd() {
		if ($("#id").val().length < 1) {
			alert("请选择用户");
			return false;
		}
		winopen("{:U('password')}?id=" + $("#id").val(), 730, 300);
	}

	function select_dept() {
		winopen("{:U('dept/winpop2')}", 730, 500);
	}

	function select_avatar() {
		winopen("{:U('popup/avatar')}?id=" + $("#id").val(), 730, 500);
	}

	function btn_search() {
		sendForm("form_search", "__SELF__");
		$("#form_search").submit();
	}

	function key_search() {
		if (event.keyCode == 13) {
			sendForm("form_search", "__SELF__");
			return false;
		}
	}

	function save() {
		if (check_form("form_data")) {
			sendForm("form_data", "{:U('save')}", "__URL__");
		}
	}

	function showdata(result) {
		for (var s in result.data) {
			set_val(s, result.data[s]);
		}
		$("#dept_name").val($("#dept_list option[value='" + $("#dept_id").val() + "']").text());
		img_url = "/{:C('SAVE_PATH')}" + $("#pic").val();
		$("#emp_pic").attr("src", img_url);
		$("#save_name").val("");
		$("#opmode").val("edit");
	}


	$(document).ready(function() {
		set_val('eq_is_del', "{$eq_is_del}");
		set_return_url();
		$(".input-date").datepicker();
		$(".sub_left_menu tbody tr").click(function() {
			$(".sub_left_menu tbody tr.active").removeClass("active");
			$(this).attr("class", "active");
			sendAjax("{:U('read')}", "id=" + $(this).attr("id"), function(data) {
				showdata(data);
			});
			return false;
		})
	});

</script>
<input type="hidden" name="ajax" id="ajax" value="1">
<select name="dept_list" id="dept_list" class="display-none">
	{:fill_option($dept_list)}
</select>
<form method="post" id="form_search" name="form_search" method="post">
	<div class="title panel panel-default">
		<div class="panel-body">
			<h3 class="col-md-8">用户管理</h3>
			<div class="col-md-4 pull-right">
				<div class="search_box">
					<div class="input-group ">
						<input  class="form-control" type="text"  onkeydown="key_search();" name="keyword" id="keyword"/>
						<div class="input-group-btn">
							<a class="btn btn-default" onclick="btn_search();" > <i class="icon-search" ></i> </a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="operate panel panel-default">
		<div class="panel-body">
			<div class="pull-left">
				<label class="radio-inline" for="eq_is_del"><b>状态:</b></label>
				<span class="checkbox">
					<select id="eq_is_del" name="eq_is_del" class="form-control col-10" onchange="search();">
						<option value="0">启用</option>
						<option value="1">禁用</option>
					</select> </span>
			</div>
			<div class="pull-right">
				<a onclick="reset_pwd()" class="btn btn-default">设置密码</a>
				<a onclick="add()"  class="btn btn-default">新增</a>
				<a onclick="save()"  class="btn btn-default">保存</a>
			</div>
		</div>
	</div>
</form>
<div class="row">
	<div class="col-md-4 sub_left_menu ">
		<table class="table table-bordered">
			<thead>
				<tr>
					<th>员工编号</th>
					<th>姓名</th>
					<th>状态</th>
				</tr>
			</thead>
			<tbody>
				<volist name="list" id="data">
					<tr id="{$data.id}">
						<td>{$data.emp_no}</td>
						<td>{$data.emp_name}</td>
						<td>{$data.is_del|status}</td>
					</tr>
				</volist>
			</tbody>
		</table>
	</div>
	<div class="col-md-8">
		<form id="form_data" name="form_data" method="post" class="form-horizontal">
			<input type="hidden" id="save_name" name="save_name">
			<input type="hidden" name="id" id="id">
			<input type="hidden" name="pic" id="pic" >
			<input type="hidden" name="opmode" id="opmode" value="edit">
			<table class="table table-bordered" >
				<tr>
					<th>
					<nobr>
						员工编号*
					</nobr></th>
					<td colspan="2">
					<input class="form-control" type="text" id="emp_no" name="emp_no"  check="require" msg="请输入员工编号">
					</td>
					<td rowspan="4"><img class="img-thumbnail col-12" id="emp_pic" ></td>
				</tr>
				<tr>
					<th>姓名*</th>
					<td colspan="2">
					<input  class="form-control" type="text" id="emp_name" name="emp_name" class="input-sm" check="require" msg="请输入姓名">
					</td>
				</tr>
				<tr>
					<th>性别</th>
					<td colspan="2">
					<select name="sex" id="sex" class="form-control col-10">
						<option  value="male">男</option>
						<option value="female">女</option>
					</select></td>
				</tr>
				<tr>
					<th>生日</th>
					<td colspan="2">
					<input type="text" id="birthday" name="birthday" readonly="readonly" class="input-date form-control">
					</td>
				</tr>
				<tr>
					<th>部门*</th>
					<td colspan="2">
					<div class="input-group ">
						<input class="form-control" name="dept_name"  id="dept_name" type="text" msg="请选择部门" check="require" readonly="readonly" />
						<input name="dept_id" id="dept_id" type="hidden" msg="请选择部门" check="require" />
						<div class="input-group-btn">
							<a class="btn btn-default" onclick="select_dept();" > <i class="icon-search" ></i> </a>
						</div>
					</div></td>
					<td colspan="2"><a onclick="select_avatar();" class="btn btn-default">上传头像</a></td>
				</tr>
				<tr>
					<th>职级*</th>
					<td>
					<select name="rank_id" id="rank_id" class="form-control" msg="请选择职级" check="require">
						<option value="">选择职级</option>
						{:fill_option($rank_list)}
					</select>
				</td>
					<th>职位*</th>
					<td>
					<select name="position_id" id="position_id" class="form-control" msg="请选择职位" check="require">
						<option value="">选择职位</option>
						{:fill_option($position_list)}
					</select></td>
				</tr>
				<tr>
					<th>
					<nobr>
						办公室电话
					</nobr></th>
					<td>
					<input type="text" id="office_tel" name="office_tel" class="form-control">
					</td>
					<th>
					<nobr>
						移动电话
					</nobr></th>
					<td>
					<input type="text" id="mobile_tel" name="mobile_tel" class="form-control">
					</td>
				</tr>
				<tr>
				<tr>
					<th>电子邮箱</th>
					<td colspan="3">
					<input type="text" id="email" name="email" class="form-control">
					</td>
				</tr>
				<tr>
					<th>
					<nobr>
						负责业务
					</nobr></th>
					<td colspan="3">
					<input type="text" id="duty" name="duty" class="form-control">
					</td>
				</tr>
				<tr>
					<th>状态</th>
					<td colspan="3">
					<select class="form-control col-10"  name="is_del" id="is_del">
						<option  value="0">启用</option>
						<option value="1">禁用</option>
					</select></td>
				</tr>
			</table>
		</form>
	</div>
</div>
